<template>
    <div id="OrdersTitle">
        <v-details :inputConfig="inputConfig" :detailData="inputData" :rules="rules"
                   ref="input"></v-details>
    </div>
</template>

<script>
    import details from 'commons/Detail'
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        props: {
            inputData: {
                type: Object,
            }
        },
        mixins: [baseMixin],
        name: "OrdersTitle",
        data() {
            return {
                addflag: false,
                rules: {
                    facility_id: [
                        {required: true, trigger: 'blur'},
                    ],
                    cust_code: [
                        {required: true, trigger: 'blur'},
                    ],
                    item: [
                        {required: true, trigger: 'blur'},
                    ],
                    lot_code: [
                        {required: true, trigger: 'blur'},
                    ],
                    added_date: [
                        {required: true, trigger: 'blur'},
                    ],
                    start_bill_date: [
                        {required: true, trigger: 'blur'},
                    ]
                },
            }
        },
        computed: {
            inputConfig() {
                return [
                    [
                        {
                            type: "select",
                            label: this.$t('bill.wareHouse'),
                            props: "facility_id",
                            options: this.getOptions("queryFacility")
                        },
                        {
                            type: "select",
                            label: this.$t('bill.customer'),
                            props: "cust_code",
                            options: this.getOptions("queryInventory")
                        },
                        {
                            type: "select",
                            label: this.$t('config.sku'),
                            props: "item",
                            options: this.getOptions("queryItem")
                        },
                        {
                            type: "input",
                            label: this.$t('config.packaging'),
                            props: "pkg"
                        },
                    ],
                    [
                        {
                            type: "input",
                            label: this.$t('bill.lot'),
                            props: "lot_code",
                        },
                        {
                            type: "input",
                            label: "UC1",
                            props: "uc1",
                        },
                        {
                            type: "input",
                            label: "UC2",
                            props: "uc2"
                        },
                        {
                            type: "input",
                            label: "UC3",
                            props: "uc3",
                        }
                    ],
                    [
                        {
                            type: "select",
                            label: "重复性账单处理规则",
                            props: "recur_code",
                            options: this.getOptions("queryRecurRule")
                        },
                        {
                            type: "date",
                            label: "已添加",
                            props: "added_date"
                        },
                        {
                            type: "date",
                            label: "开始开票",
                            props: "start_bill_date"
                        },
                        {
                            type: "date",
                            label: "上次计费",
                            props: "after_free_days"
                        },
                        {
                            type: "date",
                            label: "下一计费日期",
                            props: "next_bill_date"
                        },
                    ]
                ]
            }
        },
        methods: {},
        mounted() {
            if (Object.keys(this.$store.state.skip).length !== 0) {
                let data = this.$store.state.skip;
                if (!data.newFlag) {
                    this.addflag = true;
                }
            } else if (!this.$store.state.newFlag) {
                this.addflag = true;
            } else {
                this.addflag = false;
            }
        },
        watch: {},
        components: {
            'v-details': details
        }
    }
</script>

<style scoped>

</style>
